<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 一,手写一个Promise(链式调用)
      new Promise((resolve, reject) => {
        setTimeout(function () {
          resolve(111)
        }, 1000)
      })
        .then((value) => {
          console.log(value)
          return new Promise((resolve, reject) => {
            setTimeout(function () {
              resolve(222)
            }, 2000)
          })
        })
        .then((value) => {
          console.log(value)
          return new Promise((resolve, reject) => {
            setTimeout(function () {
              resolve(333)
            }, 3000)
          })
        })
        .then((value) => {
          console.log(value)
        })


      // 二,手写一个Promise(完全解决)
      async function fun() {
        const A = await new Promise((resolve, reject) => {
          setTimeout(function () {
            resolve(111)
          }, 1000)
        })
        console.log(A)
        const B = await new Promise((resolve, reject) => {
          setTimeout(function () {
            resolve(222)
          }, 2000)
        })
        console.log(B)
        const C = await new Promise((resolve, reject) => {
          setTimeout(function () {
            resolve(333)
          }, 3000)
        })
        console.log(C)
      }

      fun()
    </script>
  </body>
</html>
